package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.UserQueryHistory;
import com.micro.modual.extension.UserQueryHistoryExtension;
import com.micro.modual.mapper.UserQueryHistoryMapper;
import com.micro.modual.model.bo.userqueryhistory.UserQueryHistoryBO;
import com.micro.modual.service.UserQueryHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>用户搜索历史表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:09
 */
@Service("userQueryHistoryService")
public class UserQueryHistoryServiceImpl extends AbstractBasicsServiceImpl<UserQueryHistory,Long> implements UserQueryHistoryService {

    @Autowired
    private UserQueryHistoryMapper userQueryHistoryMapper;

    /**
     * <h2>新增用户搜索历史表详情</h2>
     * @param userQueryHistoryBO {@link UserQueryHistoryBO} 用户搜索历史表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addUserQueryHistory(UserQueryHistoryBO userQueryHistoryBO) {
        UserQueryHistory userQueryHistory = UserQueryHistoryExtension.converAddUserQueryHistory(userQueryHistoryBO);
        userQueryHistoryMapper.insertSelective(userQueryHistory);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改用户搜索历史表详情</h2>
     * @param userQueryHistoryBO  {@link UserQueryHistoryBO} 用户搜索历史表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editUserQueryHistory(UserQueryHistoryBO userQueryHistoryBO) {
        UserQueryHistory userQueryHistory = UserQueryHistoryExtension.converEditUserQueryHistory(userQueryHistoryBO);
        userQueryHistoryMapper.updateByPrimaryKeySelective(userQueryHistory);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除用户搜索历史表信息</h2>
     * @param id  用户搜索历史表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteUserQueryHistory(Long id) {
        userQueryHistoryMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
